-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for named profiles (RFC 2678) #6989
Conversation
This allows creating custom profiles that inherit from other profiles. For example, one can have a release-lto profile that looks like this: [profile.release-lto] inherits = "release" lto = true The profile name will also carry itself into the output directory name so that the different build outputs can be cached independently from one another. So in effect, at the `target` directory, a name will be created for the new profile, in addition to the 'debug' and 'release' builds: ``` $ cargo build --profile release-lto $ ls -l target debug release release-lto ```
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Nice! I'm looking forward to landing this. Did you have any questions or have anything you want me to look at now? I've only skimmed this so far, and the only major thing that jumped out is that all new behavior will need to be behind a feature gate (documented in features.rs). |
Should the feature gate only affect the use of the |
When resolving profile parameters for custom named profiles, we can skip 'dev' and 'release' because they are the root profiles from which all others inherit. Otherwise, for example, we fail the tests where a simple `[profile.dev]` clause is specified.
Pushed changes: fixed a bug ; fixed the build of Cargo's tests ; fixed two tests, there are 25 tests still failing which need fixing. |
The predefined 'test' and 'bench' profiles should exist even if the user did not define anything in the Cargo.toml. This also rewrites how the merging is done.
The profile returned for custom build should have the proper 'root' field value. This fixes test build_script::profile_and_opt_level_set_correctly.
Since we also for 'cargo rustc' to received '--profile check', let it be consistent with the other commands and use a predefined 'check' profile for it that inherits from "dev". Fixes tests check::rustc_check and check::rustc_check_err.
More fixes made, 12 failures remaining. |
@ehuss The The results from the current PR changes are that at least for |
I think the feature gate should cover the new As for the change in consistency for test/bench, I'm on the fence. I think it would be OK to change it now as long as it inherits the settings from dev/release. Assuming that, then I think you should go ahead and update the |
Before the RFC, the 'clean' command would have cleaned entirety of target/ unless `--release` is specified - in that case it would have cleaned only `target/release`. Initial commit broke that. Now, passing `--profile=NAME` will clean the directory related to profile `NAME` via the dir-name setting. `--release` is supported for backward compatibility.
New code relies on a BTreeMap, rather than handed coded calls.
Not sure if you saw my question about I'll try to get back to you on the mode issue, I'd like to talk to the rest of the team about it. |
|
☔ The latest upstream changes (presumably #7421) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #7425) made this pull request unmergeable. Please resolve the merge conflicts. |
We discussed the issues with how targets relate to profiles (such as in The main issue left is that I don't think there should be any changes to existing behavior without the use of unstable flags. Can you go through and make sure the original behavior is retained unless
|
The effects over the profile used by targets are made conditional in this commit, using the old scheme if the `named-profiles` feature is disabled. This also affects the `profile_targets` tests, which now have two modes - stable, and nightly with the feature enabled.
…e=check` And a small cleanup in `base_profile` to make the logic parallel to the one in `get_profile`.
Done changes to keep original behavior, except regarding the |
Thanks so much! This looks great! I'll try to follow up on the tracking issue with some more things to discuss. @bors r+ |
📌 Commit fad192d has been approved by |
Support for named profiles (RFC 2678) Tracking issue: #6988 Implementation according to the [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2678-named-custom-cargo-profiles.md).
☀️ Test successful - checks-azure |
@ehuss, previously misguided attempts to affect debug builds via |
Hm, so to be clear, it now issues an error if you don't have the feature enabled and when you do enable the feature, it will require an I think I'm fine with that for now. It was an invalid configuration before (it was ignored other than the warning). I don't think we need to be backwards compatible with all invalid configurations. We may want to reconsider the warning in the future, but doesn't seem too important. |
Tracking issue: #6988
Implementation according to the RFC.